﻿//-----------------------------------------------------------------------
// <copyright file="User.cs" company="deixei.com">
//     Copyright (c) deixei.com. All rights reserved.
// </copyright>
// <author>Marcio Parente</author>
//---------------------------------------------------------------------
namespace Deixei.Domain
{
    using System;
    using System.Collections.Generic;
    using System.ComponentModel.DataAnnotations;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;
    using System.Web.Script.Serialization;

    /// <summary>
    /// User class, represents a registered user. Person that uses the application.
    /// </summary>
    public class User
    {
        /// <summary>
        /// Gets or sets the user id.
        /// </summary>
        /// <value>
        /// The user id.
        /// </value>
        [Key]
        public virtual int UserId
        {
            get;
            set;
        }

        /// <summary>
        /// Gets or sets the username.
        /// </summary>
        /// <value>
        /// The username.
        /// </value>
        [Required]
        public virtual String Username
        {
            get;
            set;
        }

        /// <summary>
        /// Gets or sets the email.
        /// </summary>
        /// <value>
        /// The email.
        /// </value>
        [Required]
        public virtual String Email
        {
            get;
            set;
        }

        /// <summary>
        /// Gets or sets the password.
        /// </summary>
        /// <value>
        /// The password.
        /// </value>
        [Required, DataType(DataType.Password)]
        public virtual String Password
        {
            get;
            set;
        }

        /// <summary>
        /// Gets or sets the first name.
        /// </summary>
        /// <value>
        /// The first name.
        /// </value>
        public virtual String FirstName
        {
            get;
            set;
        }
        /// <summary>
        /// Gets or sets the last name.
        /// </summary>
        /// <value>
        /// The last name.
        /// </value>
        public virtual String LastName
        {
            get;
            set;
        }

        /// <summary>
        /// Gets or sets the comment.
        /// </summary>
        /// <value>
        /// The comment.
        /// </value>
        [DataType(DataType.MultilineText)]
        public virtual String Comment
        {
            get;
            set;
        }

        /// <summary>
        /// Gets or sets the is approved.
        /// </summary>
        /// <value>
        /// The is approved.
        /// </value>
        public virtual Boolean IsApproved
        {
            get;
            set;
        }
        /// <summary>
        /// Gets or sets the password failures since last success.
        /// </summary>
        /// <value>
        /// The password failures since last success.
        /// </value>
        public virtual int PasswordFailuresSinceLastSuccess
        {
            get;
            set;
        }
        /// <summary>
        /// Gets or sets the last password failure date.
        /// </summary>
        /// <value>
        /// The last password failure date.
        /// </value>
        public virtual DateTime? LastPasswordFailureDate
        {
            get;
            set;
        }
        /// <summary>
        /// Gets or sets the last activity date.
        /// </summary>
        /// <value>
        /// The last activity date.
        /// </value>
        public virtual DateTime? LastActivityDate
        {
            get;
            set;
        }
        /// <summary>
        /// Gets or sets the last lockout date.
        /// </summary>
        /// <value>
        /// The last lockout date.
        /// </value>
        public virtual DateTime? LastLockoutDate
        {
            get;
            set;
        }
        /// <summary>
        /// Gets or sets the last login date.
        /// </summary>
        /// <value>
        /// The last login date.
        /// </value>
        public virtual DateTime? LastLoginDate
        {
            get;
            set;
        }
        /// <summary>
        /// Gets or sets the confirmation token.
        /// </summary>
        /// <value>
        /// The confirmation token.
        /// </value>
        public virtual String ConfirmationToken
        {
            get;
            set;
        }
        /// <summary>
        /// Gets or sets the create date.
        /// </summary>
        /// <value>
        /// The create date.
        /// </value>
        public virtual DateTime? CreateDate
        {
            get;
            set;
        }
        /// <summary>
        /// Gets or sets the is locked out.
        /// </summary>
        /// <value>
        /// The is locked out.
        /// </value>
        public virtual Boolean IsLockedOut
        {
            get;
            set;
        }
        /// <summary>
        /// Gets or sets the last password changed date.
        /// </summary>
        /// <value>
        /// The last password changed date.
        /// </value>
        public virtual DateTime? LastPasswordChangedDate
        {
            get;
            set;
        }
        /// <summary>
        /// Gets or sets the password verification token.
        /// </summary>
        /// <value>
        /// The password verification token.
        /// </value>
        public virtual String PasswordVerificationToken
        {
            get;
            set;
        }
        /// <summary>
        /// Gets or sets the password verification token expiration date.
        /// </summary>
        /// <value>
        /// The password verification token expiration date.
        /// </value>
        public virtual DateTime? PasswordVerificationTokenExpirationDate
        {
            get;
            set;
        }

        /// <summary>
        /// Gets or sets the roles.
        /// </summary>
        /// <value>
        /// The roles.
        /// </value>
        [ScriptIgnore]
        [Display(Name = "Roles", Description = "List of Roles that this User has.", ShortName = "Roles")]
        public virtual ICollection<Role> Roles
        {
            get;
            set;
        }

        [ScriptIgnore]
        [Display(Name = "Application", Description = "Application that this User belongs.", ShortName = "App.")]
        public virtual WebAppPortfolio Application
        {
            get;
            set;
        }

    }

}
